package com.kingsoft.labs.tangram.test;

import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Query;

public class DBTestCase extends LocalDatastoreTestCase {
	@PersistenceCapable(identityType = IdentityType.APPLICATION)
	public static class Bean {
		@PrimaryKey
		@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
		Key id;
		@Persistent
		private String name;
		public Key getId() {
			return id;
		}
		public void setId(Key id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
	}

	public void testInsert() {
		Query query =new Query("select from " + Bean.class.getName());
		List<Bean> results = null;
		int n = DatastoreServiceFactory.getDatastoreService()
				.prepare(query).countEntities();
		assertTrue(n > 0);
		System.out.println(n);
	}
}
